<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
  <title>Boost Header policy</title>
  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  <link rel="icon" href="/favicon.ico" type="image/ico" />
  <link rel="stylesheet" type="text/css" href=
  "/style-v2/section-development.css" />
  <!--[if IE 7]> <style type="text/css"> body { behavior: url(/style-v2/csshover3.htc); } </style> <![endif]-->
</head><!--
Note: Editing website content is documented at:
https://www.boost.org/development/website_updating.html
-->

<body>
  <div id="heading">
    <!--#include virtual="/common/heading.html" -->
  </div>

  <div id="body">
    <div id="body-inner">
      <div id="content">
        <div class="section" id="intro">
          <div class="section-0">
            <div class="section-title">
              <h1>Boost Header policy</h1>
            </div>

            <div class="section-body">
              <p>Header files are the place where a library comes into
              contact with user code and other libraries. To co-exist
              peacefully and productively, headers must be "good
              neighbors".</p>

              <p>Here are the standards for boost headers. Many of these are
              also reasonable guidelines for general use.</p>

              <ul>
                <li>Header filenames should have a .hpp (lowercase)
                extension.</li>

                <li>Unless multiple inclusion is intended, wrap the header in
                #ifndef guards. Use a naming convention that minimizes the
                chance of clashes with macro names from other's code. The
                <a href="#SampleHeader">sample header</a> uses the Boost
                convention of all uppercase letters, with the header name
                prefixed by the namespace name, and suffixed with HPP,
                separated by underscores.</li>

                <li>Wrap the header contents in a namespace to prevent global
                namespace pollution. The namespace approach to pollution
                control is strongly preferred to older approaches such as
                adding funny prefixes to global names. Libraries which are
                designed to work well with other Boost libraries should be
                placed in namespace <tt>boost</tt>.</li>

                <li>Make sure that a translation unit consisting of just the
                contents of the header file will compile successfully.</li>

                <li>Place the header file in a sub-directory to prevent
                conflict with identically named header files in other
                libraries. The parent directory is added to the compiler's
                include search path. Then both your code and user code
                specifies the sub-directory in <tt>#include</tt> directives.
                Thus the header <a href="#SampleHeader">sample header</a>
                would be included by <tt>#include
                &lt;boost/furball.hpp&gt;</tt>. (Note, including from current
                file directory using <tt>#include "furball.hpp"</tt> syntax
                is discouraged .)</li>

                <li>The preferred ordering for class definitions is public
                members, protected members, and finally private members.</li>

                <li>Include the boost/config.hpp <a href=
                "/doc/libs/release/libs/config/config.htm">configuration
                header</a> if there is a need to deal with compiler or
                platform configuration issues.</li>
              </ul>

              <h2><a name="SampleHeader" id="SampleHeader"></a>Sample
              Header</h2>
              <pre>
//  Boost general library furball.hpp header file ---------------------------//

  &lt;<i> Copyright and license notice</i>, as indicated in the <a href=
"/users/license.html">license page</a> &gt;

//  See https://www.boost.org/ for latest version.

#ifndef BOOST_FURBALL_HPP
#define BOOST_FURBALL_HPP

namespace boost {

//  Furball class declaration  -----------------------------------------------//

  class furball
  {
    public: 
      void throw_up();
    private:
      int whatever;
  };  // furball

} // namespace

#endif  // include guard
</pre>

              <h2>Coding Style</h2>

              <p>The alert reader will have noticed that the <a href=
              "#SampleHeader">sample header</a> employs a certain coding
              style for indentation, positioning braces, commenting ending
              braces, and similar formatting issues. These stylistic issues
              are viewed as personal preferences and are not part of the
              Boost Header Policy.</p>
            </div>
          </div>
        </div>
      </div>

      <div id="sidebar">
        <!--#include virtual="/common/sidebar-common.html" -->
        <!--#include virtual="/common/sidebar-development.html" -->
      </div>

      <div class="clear"></div>
    </div>
  </div>

  <div id="footer">
    <div id="footer-left">
      <div id="revised">
        <p>Revised $Date: 2007-10-22 22:55:52 +0100 (Mon, 22 Oct 2007) $</p>
      </div>

      <div id="copyright">
        <p>Copyright Beman Dawes 1998.</p>
      </div><!--#include virtual="/common/footer-license.html" -->
    </div>

    <div id="footer-right">
      <!--#include virtual="/common/footer-banners.html" -->
    </div>

    <div class="clear"></div>
  </div>
</body>
</html>
